/*
 * 日期格式化
 */
package com.security.lasys.object;

import java.util.HashMap;

public class GetDate
{
	HashMap<String, String> eventAttrs = new HashMap<String, String>();
	HashMap<String, String> monHash = new HashMap<String, String>();

	public GetDate(HashMap<String, String> eventAttrs)
	{
		this.eventAttrs = eventAttrs;

		monHash.put("Jan", "01");
		monHash.put("Feb", "02");
		monHash.put("Mar", "03");
		monHash.put("Apr", "04");
		monHash.put("May", "05");
		monHash.put("Jun", "06");
		monHash.put("Jul", "07");
		monHash.put("Aug", "08");
		monHash.put("Sep", "09");
		monHash.put("Oct", "10");
		monHash.put("Nov", "11");
		monHash.put("Dec", "12");
	}

	public HashMap<String, String> getDate()
	{
		String date = "";
		String year = eventAttrs.get("year");
		String month = eventAttrs.get("month");
		String day = eventAttrs.get("day");
		String hour = eventAttrs.get("hour");
		String min = eventAttrs.get("min");
		String sec = eventAttrs.get("sec");
		if (year != null) {
			if (year.length() == 2) {
				date = "20" + year + "-";
			} else if (year.length() == 4) {
				date = year + "-";
			} else {
				date = "0000-";
			}
		} else {
			date = "0000-";
		}

		if (month.length() == 3) {
			date = date + monHash.get(month) + "-";
		} else if (month.length() >= 0) {
			date = date + month + "-";
		} else {
			date = date + "MM" + "-";
		}

		date = date + day + " ";

		date = date + hour + ":" + min + ":" + sec;

		eventAttrs.put("date", date);
		eventAttrs.remove("year");
		eventAttrs.remove("month");
		eventAttrs.remove("day");
		eventAttrs.remove("hour");
		eventAttrs.remove("min");
		eventAttrs.remove("sec");

		return eventAttrs;
	}

}
